%% saveDistribution
%  Version 1.0
%  Author: Adeyinka Lesi
%  Date: 6/24/15
%  Project: Tumor Growth, Discrete Form
% saveDistribution writes out the data in a matrix to a file
% loc: string; file directory and name
% dist: MxN matrix; contians data
% x: 1xM vector; value corresponding to rows of matrix
% t: 1xN vector; value corresonding to columns of matrix

function [] = saveDistribution(loc,distrib,x,t)


% create file, assuming directories are already created
file = fopen(loc,'w');

% write time points
fprintf(file,'%8s  ','NaN');
fprintf(file,'%23d  ',t);
fprintf(file,'\n');
% write data
for i = 1:length(x)
    fprintf(file,'%8d  ',x(i));
    fprintf(file,'%+0.16e  ',distrib(i,:));
    fprintf(file,'\n');
end

fclose(file);